package com.kmxd.ams.controller.system;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kmxd.ams.client.system.IConfI18nDetailSvc;
import com.kmxd.ams.client.system.dto.ConfI18nDetailAddDTO;
import com.kmxd.ams.client.system.dto.ConfI18nDetailEditDTO;
import com.kmxd.ams.client.system.dto.ConfI18nDetailQueryDTO;
import com.kmxd.ams.client.system.vo.ConfI18nDetailListVO;
import com.kmxd.ams.client.system.vo.ConfI18nDetailVO;
import com.kmxd.ams.core.common.enums.LogLevelEnum;
import com.kmxd.ams.core.common.enums.LogTypeEnum;
import com.kmxd.ams.core.log.annotation.AutoLog;
import com.kmxd.ams.core.result.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 国际化语言详情表 前端控制器
 *
 * @author ZuoLG
 * @since 2022-07-14
 */
@RestController
@Tag(name = "国际化语言详情表")
@RequestMapping("/confI18nDetail")
@AllArgsConstructor
public class ConfI18nDetailCtl {

  private IConfI18nDetailSvc confI18nDetailService;

  /** 分页查询 */
  @Operation(summary = "分页查询")
  @GetMapping("/selectPage")
  @AutoLog(module = "国际化语言详情表", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.LOW, title = "分页查询")
  public R<Page<ConfI18nDetailListVO>> selectPage(Page reqPage, ConfI18nDetailQueryDTO req) {
    return R.success(confI18nDetailService.selectPage(reqPage, req));
  }

  /** 新增 */
  @Operation(summary = "新增")
  @PostMapping("/add")
  @SaCheckPermission("system:confI18nDetail:add")
  @AutoLog(module = "国际化语言详情表", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.LOW, title = "新增")
  public R<Void> add(@Validated @RequestBody ConfI18nDetailAddDTO req) {
    confI18nDetailService.add(req);
    return R.success();
  }

  /** 修改 */
  @Operation(summary = "修改")
  @PostMapping("/edit")
  @SaCheckPermission("system:confI18nDetail:edit")
  @AutoLog(module = "国际化语言详情表", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.HIGH, title = "修改")
  public R<Void> edit(@Validated @RequestBody ConfI18nDetailEditDTO req) {
    confI18nDetailService.edit(req);
    return R.success();
  }

  /** 删除 */
  @Operation(summary = "删除")
  @PostMapping("/remove")
  @SaCheckPermission("system:confI18nDetail:remove")
  @AutoLog(
      module = "国际化语言详情表",
      type = LogTypeEnum.SYSTEM,
      level = LogLevelEnum.HIGH_RISK,
      title = "删除")
  public R<Void> remove(@RequestParam String ids) {
    confI18nDetailService.remove(ids);
    return R.success();
  }

  /** 查看 */
  @Operation(summary = "查看")
  @GetMapping("/view")
  @AutoLog(module = "国际化语言详情表", type = LogTypeEnum.SYSTEM, level = LogLevelEnum.LOW, title = "查看")
  public R<ConfI18nDetailVO> view(@RequestParam Long id) {
    return R.success(confI18nDetailService.view(id));
  }
}
